//
//  OverlayView.m
//  PlayMovie
//
//  Created by 畑圭輔 on 09/10/13.
//  Copyright 2009 Keisuke Hata. All rights reserved.
//

#import "OverlayView.h"

NSString * const kOverlayButtonClickNotification = @"kOverlayButtonClickNotification";

@implementation OverlayView

// ボタンをタップした時のイベント
- (void) clickButton
{
	NSLog(@"Click");
	
	// 登録したボタンタップ通知を発行させる
	NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
	[nc postNotificationName:kOverlayButtonClickNotification object:nil];
}

- (id) initWithFrame:(CGRect)frame
{
	if( self = [super initWithFrame:frame] )
	{
		// Skipボタンを生成
		UIButton *button = [[UIButton alloc] initWithFrame:frame];
		[button setBackgroundImage:[UIImage imageNamed:@"skip_button01.png"] 
						  forState:UIControlStateNormal];
		[button setBackgroundImage:[UIImage imageNamed:@"skip_button02.png"] 
						  forState:UIControlStateHighlighted];
		
		[button addTarget:self 
					action:@selector(clickButton) 
					forControlEvents:UIControlEventTouchUpInside];
		
		[self addSubview:button];
		[button release];
	
		// 横画面なので、ボタンを回転させて配置
		CGAffineTransform transform = self.transform;
		transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
		transform = CGAffineTransformTranslate( 
											   transform, 
											   SCREEN_HEIGHT - SKIP_BUTTON_W - 20, 
											   -20 
											   );
		self.transform = transform;
	}
	return self;
}

@end
